#include <iostream>
using namespace std;

int main(int argc, char const *argv[])
{
  int arr[9] = {4, 2, 8, 0, 5, 7, 1, 3, 9};

  cout << "排序前：" << endl;
  for (int i = 0; i < 9; i++)
  {
    cout << arr[i] << ' ';
  }
  cout << endl;

  // 开始冒泡排序
  for(int i = 0; i < 9 - 1; i++)
  {
    for(int j = 0; j < 9 - 1 - 1; j++)
    {
      if (arr[j] > arr[j+1])
      {
        int temp = arr[j];
        arr[j] = arr[j+1];
        arr[j+1] = temp;
      }
      
    }
  }

  cout << "排序后：" << endl;
  for (int i = 0; i < 9; i++)
  {
    cout << arr[i] << ' ';
  }
  cout << endl;

  return 0;
}